<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>01-非受控组件</title>
  <script src="../其他/js/react.development.js"></script>
  <script src="../其他/js/react-dom.development.js"></script>
  <!-- Don't use this in production: -->
  <script src="../其他/js/babel.min.js"></script>
  <!-- 添加了一个 PropTypes 对象, 可以对props属性进行限制 -->
  <script src="https://cdn.staticfile.org/prop-types/15.5.10/prop-types.js"></script>
</head>
<body>
  <div id="root"></div>
  <script type="text/babel">
    class Login extends React.Component {
      handleSubmit = (event) => {
        // 阻止默认行为
        event.preventDefault()
        const {username, password} = this
        alert(`你的用户名是${username.value}, 你的密码是${password.value}`)
      }
      render() {
        // 现用现取就是非受控组件,不推荐使用
        return (
          <form onSubmit={this.handleSubmit}>
            <input ref={c => this.username = c} type="text" name="username"/>  <br/>
            <input ref={c => this.password = c} type="password" name="password"/>   <br/>
            <button>提交</button>
          </form>
        )
      }
    }
    ReactDOM.render(<Login/>,document.getElementById('root'))
  
  </script>
</body>
</html>